package com.candy.shopproduct.controller;

import com.candy.entity.Product;
import com.candy.shopproduct.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    ProductService productService;

    @GetMapping("/product/{pid}")
    public Product getProduct(@PathVariable Integer pid){
        Product product=productService.getProductById(pid);
        System.out.println("查询到商品："+product);
        return product;

    }
    @RequestMapping("/editProduct")
    public String editProduct(Integer pid){
        System.out.println(pid);
        productService.editProduct(pid);
        return "库存-1";

    }

}
